package cn.wizzer.app.user.modules.service.impl;

import cn.wizzer.app.user.modules.models.ChatReport;
import cn.wizzer.app.user.modules.models.vo.ChatReportVo;
import cn.wizzer.app.user.modules.services.ChatReportService;
import cn.wizzer.framework.base.service.BaseServiceImpl;
import cn.wizzer.framework.base.service.CommonDBService;
import cn.wizzer.framework.page.Pagination;
import com.alibaba.dubbo.config.annotation.Service;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

@IocBean(args = {"refer:dao"})
@Service(interfaceClass = ChatReportService.class)
public class ChatReportServiceImpl extends BaseServiceImpl<ChatReport> implements ChatReportService {
    @Inject
    private CommonDBService dbService;

    public ChatReportServiceImpl(Dao dao) {
        super(dao);
    }

    public Pagination listPage(int pageNo, int pageSize) {
        Sql sql = Sqls.create("select c.*, u.nickName as toUserName " +
                "from user_chat_report c " +
                "left join user u on u.id = c.to_user " +
                "order by c.ctAt desc ");
        Sql countSql = Sqls.create("select count(1) from user_chat_report ");
        return dbService.listPage(ChatReportVo.class , pageNo, pageSize, sql.toString(), countSql.toString());
    }
}
